package com.yc.io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.nio.file.Paths;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SmFile {
	String abc = "cc";
	private final Logger log = LoggerFactory.getLogger(this.getClass());
	
	public void testLog() {
		String abc = "dd";
		log.info("11111");
		log.error("aaa");
	} 
	
	public void testPaths() {
		Path path = Paths.get("F:/worksource/JKCT/HB/bug/20190716");
		System.out.println(path.getParent().getFileName());
		
	}
	
	/**
	 * 可以任意拼接成路径
	 */
	public void m2() {
		Path path = Paths.get("F:/worksource/JKCT", "/bug");
		System.out.println(path.toString());
	}
	
	public void m3() {
		File f = new File("F:/worksource/JKCT/HB/temp/测试菜品/炒青菜.jpg");
		System.out.println(f.lastModified());//1530175007788
	}
	
	/**
	 * 获取文件大小
	 */
	public void m4() {
		File f = new File("F:\\worksource\\JKCT\\HB\\temp\\pom.xml");
		
		System.out.println("len=" +f.length());
		try {
			InputStream fs = new FileInputStream(f);
			System.out.println("avilableLen=" + fs.available());
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}

	public static void main(String[] args) {
		SmFile sf = new SmFile();
//		sf.testLog();
//		sf.testPaths();
//		sf.m2();
//		sf.m3();
		sf.m4();

	}

}
